package com.twu.biblioteca.data;

/**
 * Created with IntelliJ IDEA.
 * User: zgq
 * Date: 13-7-4
 * Time: 下午9:50
 * To change this template use File | Settings | File Templates.
 */
public class Movie {
    public static final int NOT_RATED = -1;
    public static final String NOT_RATED_PRESENTATION = "N/A";
    private String movieName;
    private int movieYear;
    private String movieDirector;
    private int rating;

    public Movie(String movieName, int movieYear, String movieDirector) {
        this.movieName = movieName;
        this.movieYear = movieYear;
        this.movieDirector = movieDirector;
        this.rating = NOT_RATED;
    }


    public String ratingPresentation() {
        String ratingPresentation = NOT_RATED_PRESENTATION;
        if(rating != NOT_RATED) {
            ratingPresentation = "";
            for(int times = 0; times < rating; times++) ratingPresentation += "*";
        }
        return ratingPresentation;
    }

    public void grade(int rating) {
        if(rating >=1 && rating <=10)
            this.rating = rating;
    }

    public String toString() {
        return movieName+"\t"+movieYear+"\t"+movieDirector+"\t"+ratingPresentation();
    }
}
